﻿@{
    ViewBag.Title = "Login";
}

<div class="Content">

<div style="width:350px;">
<br />
<fieldset>
    <legend>Autenticarse</legend>
    <br />
        <table width="100%">
        <tr>
            <td width="60%">Login: </td>
            <td width="40%"><input type="text" id="txtlogin" value="" /></td>
        </tr>
        <tr>
            <td>Password:</td>
            <td><input type="password" id="txtpass" value="" /></td> 
        </tr>
        <tr>
        <td colspan="2" style="text-align:right">
            <a href="#"><span class="validarCliente">Aceptar</span></a>
        </td>
        </tr>        
        <tr>
        <td colspan="2">
            <span id="msgLogin" class="field-validation-error" style="display: none;">&nbsp;</span>
        <br />
        Si no esta registrado, <a href="@Url.Action("Register", "Cliente")">pulse aquí</a></td>
        </tr>
        </table>    
</fieldset>

</div>


</div>

<script type="text/javascript">

    $(".validarCliente").live("click", function () {
        var login = $('#txtlogin').val();
        var pass = $('#txtpass').val(); ;

        $.post('/Cliente/ValidaLogin/?login=' + login + "&pass=" + pass, function (data) {
            if (String(data) == "exito") {
                window.location.href = "/Restaurante/ListReserva";
            } else {
                $("#msgLogin").text(data);
                $("#msgLogin").show();
            }
        });
    });

</script>